const swaggerJsdoc = require('swagger-jsdoc');
const swaggerUi = require('swagger-ui-express');

const options = {
  definition: {
    openapi: '3.0.0',
    info: {
      title: 'FinanceApp API',
      version: '1.0.0',
      description: '个人财务管理应用的API文档',
    },
    servers: [
      {
        url: 'http://localhost:3003',
        description: '开发服务器',
      },
    ],
    components: {
      securitySchemes: {
        bearerAuth: {
          type: 'http',
          scheme: 'bearer',
          bearerFormat: 'JWT',
        },
      },
    },
    security: [
      {
        bearerAuth: [],
      },
    ],
  },
  apis: ['./routes/*.js', './controllers/*.js'], // 指定包含API注释的文件路径
};

const specs = swaggerJsdoc(options);
module.exports = { specs, swaggerUi };